home *** CD-ROM | disk | FTP | other *** search
- #include "main.h"
- #include "cursors.h"
-
- static int toolCurs = pencilCurs;
-
- /*******************************************************
- * *
- * This updates the cursor, and sets up the mouseGood region for use with Wait- *
- * NextEvent. The cursor is only actually set if it needs to be. *
- * *
- *******************************************************/
-
- updateMouse( mouseGood )
- RgnHandle mouseGood;
- {
- Point where;
- RgnHandle tempRgn;
- dataHandle theDataHand;
- WindowPtr theWindow;
- dataPtr theData;
- int cursor, cmdMod;
-
- cursor = arrowCurs;
- theWindow = FrontWindow();
- if( theWindow && (((WindowPeek)theWindow)->windowKind >= userKind )) {
- theDataHand = ( dataHandle )GetWRefCon( theWindow );
- HLock( theDataHand );
- theData = *theDataHand;
- RectRgn( mouseGood, &(( **theDataHand ).dataRect ));
- cmdMod = getModifiers() & cmdKey;
- if( theData->isSelect && !cmdMod )
- DiffRgn( mouseGood, theData->selRgn, mouseGood );
- GetMouse( &where );
- if( PtInRgn( where, mouseGood )) {
- cursor = cmdMod ? marqeeCurs : toolCurs;
- OffsetRgn( mouseGood, -theWindow->portBits.bounds.left, -theWindow->portBits.bounds.top );
- } else {
- OffsetRgn( mouseGood, -theWindow->portBits.bounds.left, -theWindow->portBits.bounds.top );
- tempRgn = NewRgn();
- RectRgn( tempRgn, &( screenBits.bounds ));
- DiffRgn( tempRgn, mouseGood, mouseGood );
- DisposeRgn( tempRgn );
- }
- HUnlock( theDataHand );
- } else setBigRgn( mouseGood );
- forceCurs( cursor );
- }
-
- /*******************************************************
- * *
- * Used to control access to the current value of toolCurs. This merely reduces *
- * the number of global variables hanging about. *
- * *
- *******************************************************/
-
- setToolCurs( newTool )
- int newTool;
- {
- toolCurs = newTool;
- }
-
- getToolCurs() {
- return( toolCurs );
- }
-
- /*******************************************************
- * *
- * ForceCurs sets the current cursor. If the badCursFlag is passed, it knows *
- * that what it thinks is the current cursor may be wrong, and it corrects this. *
- * At cursor update time, this is called to make the cursor correct, if it is not. *
- * *
- *******************************************************/
-
- forceCurs( newCurs )
- int newCurs;
- {
- CursHandle theCursor;
- static int oldCurs = arrowCurs;
-
- if( newCurs != oldCurs ) {
- if( newCurs == badCursFlag )
- newCurs = oldCurs;
- if( newCurs != arrowCurs ) {
- theCursor = GetCursor( baseCursID + newCurs );
- if( theCursor ) SetCursor( *theCursor );
- else SetCursor( &arrow );
- } else SetCursor( &arrow );
- oldCurs = newCurs;
- }
- }